package define.Demo_04;

import java.util.Scanner;

public class 金额转换 {
    public static void main(String[] args) {
        Scanner sc  = new Scanner(System.in);
        System.out.println("请输入金额");
        String input = sc.nextLine();
        System.out.println(change(input));
    }
    public static String change(String input){
        StringBuffer sb = new StringBuffer("零佰零拾零万零仟零佰零拾零元");
        String[] arr = {"壹","贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖", "拾"};
        int temp = 0;
        for (int i = input.length(); i > 0; i--) {
            int index = input.charAt(i-1) - '0';
            if (index != 0) {
                int pos = sb.length() - (2 +temp * 2);
                temp++;
                sb.setCharAt(pos,arr[index-1].charAt(0));
            }
        }
        return sb.toString();
    }
}
